package com.cnswhy.cloud.server.common.entity.enumeration;

import com.cnswhy.cloud.common.core.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-27
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "SmsType", description = "短信类型 #SmsType{SMS_CODE:验证码;SPELL_SUCCESS:拼团成功;SPELL_FOR_PAY:拼团支付;-枚举")
public enum SmsType implements BaseEnum {

    /**
     * SMS_CODE="验证码"
     */
    SMS_CODE("验证码"),
    /**
     * SPELL_SUCCESS="拼团成功"
     */
    SPELL_SUCCESS("拼团成功"),
    /**
     * SPELL_FOR_PAY="拼团支付"
     */
    SPELL_FOR_PAY("拼团支付"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static SmsType match(String val, SmsType def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static SmsType get(String val) {
        return match(val, null);
    }

    public boolean eq(SmsType val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "SMS_CODE,SPELL_SUCCESS,SPELL_FOR_PAY", example = "SMS_CODE")
    public String getCode() {
        return this.name();
    }

}
